<!--
 * @Author: wrh123 482597539@qq.com
 * @Date: 2024-01-11 17:42:50
 * @LastEditors: wrh123 482597539@qq.com
 * @LastEditTime: 2024-01-18 21:33:00
 * @FilePath: /vue-admin/src/views/Tradingacct/components/passWoedEdit.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="passWoedEdit">
    <el-dialog title="密码编辑" :visible="passVisible" width="20%" :before-close="handleClose">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item prop="accountPassword" label="新密码">
          <el-input v-model="form.accountPassword" size="mini" style="width: 160px;" placeholder="请输入新密码" />
        </el-form-item>
      </el-form>
      <el-row type="flex" justify="center" style="margin-top: 20px;">
        <el-button size="mini" @click="handleClose">取 消</el-button>
        <el-button size="mini" type="primary" @click="delBtnOK">确 定</el-button>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
import { updatePwd } from '@/api/Tradingacct'
export default {
  name: 'VueAdminPassWoedEdit',
  props: {
    passVisible: {
      default: false,
      type: Boolean
    },
    accoutId: {
      default: null,
      type: Number
    },
    accountPasswords: {
      default: '',
      type: String
    }
  },
  data() {
    return {
      form: {
        accountPassword: null,
        id: null
      },
      rules: {
        accountPassword: [
          { required: true, message: '请输入密码', trigger: 'blur' }
        ]
      }
    }
  },
  watch: {
    accountPasswords(old, nev) {
      // console.log(old,'nev');
      this.form.accountPassword = old
    },
    accoutId(old, nev) {
      this.form.id = old
    }
  },

  mounted() {

  },

  methods: {
    // 取消
    handleClose() {
      this.$refs.form.resetFields()
      this.$emit('update:passVisible', false)
    },
    // 确定
    async delBtnOK() {
      await this.$refs.form.validate()
      this.$confirm('请确认经纪商的密码是否已经修改?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        const res = await updatePwd(this.form)
        // console.log('res',res);
        // 调用直接修改分控的接口
        this.$message({
          type: 'success',
          message: '密码修改成功'
        })
        this.$emit('refresh')
        this.handleClose()
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消修改'
        })
      })

    },
    // getDecrt(id) {
    //   console.log('id', id)
    //   // this.form.passWord = id
    // }
  }
}
</script>

<style lang="scss" scoped></style>
